<template>
	<view class="userLayout pageBg" v-if="userInfo">
		<custom-nav-bar title = "" :isShowSearch = "false"></custom-nav-bar>
		<view class="userInfo">
		   <view class="avatar">
		   	  <image src="../../static/images/logo.png" mode="aspectFill"></image>
		   </view>
		   <view class="ip">{{userInfo.IP}}</view>
		   <view class="address">来自于:{{userInfo.address.city || userInfo.address.province || userInfo.address.country }}</view>
		</view> 
		<view class="section">
			<view class="list">
				<view class="row" v-for="(item,index) in sectionTop" :key="item" @click="onClick(index)">
					<view class="left">
						<uni-icons type="download-filled" size="20" color="#28b389"></uni-icons>
						<view class="text">{{item}}</view>
					</view>
					<view class="right">
						<view class="text" v-if ="index == 0">{{userInfo.downloadSize}}</view>
						<view class="text" v-else-if="index == 1">{{userInfo.scoreSize }}</view>
						<uni-icons type="right" size="15" color="#aaa"></uni-icons>
					</view>
				</view>
				<!-- #ifdef H5 -->
					<button class = "iphone">拨打电话</button>
				<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
					<button open-type="contact">联系客服</button>
				 <!-- #endif -->
				 
			</view>
		</view>
		<view class="section">
			<view class="list">
				<view class="row" v-for="item in sectionBottom" :key="item">
					<view class="left">
						<uni-icons type="download-filled" size="20" color="#28b389"></uni-icons>
						<view class="text">{{item}}</view>
					</view>
					<view class="right">
						<view class="text"></view>
						<uni-icons type="right" size="15" color="#aaa"></uni-icons>
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="loadingLayout" v-else>
		<uni-load-more status="loading"></uni-load-more>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { GetApiUserInfo } from "@/api/api.js"
const sectionTop = ref(["我的下载","我的评分","联系客服"])
const sectionBottom = ref(["订阅更新","常见问题"])
let dd = ref(false)
const userInfo = ref(null)
const getUserInfo = async()=>{
	let res =  await  GetApiUserInfo()
	console.log(res.data.data)
	userInfo.value= res.data.data
}
getUserInfo()

function onClick(index){
	console.log(index)
	if (index == 0) {
		uni.navigateTo({
			url:"/pages/classlist/classlist?name=我的下载&type=download"
		})
	} else if (index == 1){
		uni.navigateTo({
			url:"/pages/classlist/classlist?name=我的评分&type=score"
		})
	}
}

</script>

<style lang="scss" scoped>
.userLayout {
	.userInfo {
		//background-color: red;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding: 50rpx 0;

		
		.avatar {
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			overflow: hidden;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.ip {
			margin-top: 20rpx;
			color: #333;
			font-size: 44rpx;
		}
		.address {
			margin-top: 15rpx;
			color: #aaa;
			font-size: 28rpx;
		}
	}
	.section {
		width: 690rpx;
		margin: 50rpx auto;
		border: 1px solid #eee;
		border-radius: 10rpx;
		box-shadow: 0 0 30rpx rgba(0,0,0,0.05);
		
		.list {
			.row {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 12rpx  30rpx;
				height: 100rpx;
				border-bottom: 1px solid #eee;
				background-color: #fff;
				
				&:last-child{border-bottom: 0;}
				.left {
					display: flex;
					align-items: center;
					.text {
						margin-left: 20rpx;
						color: #666;
					}
	
				}
				.right {
					display: flex;
					align-items: center;
					.text {
						font-size: 28rpx;
						color: #aaa;
						margin-right: 5rpx;
					}
				}
			}
		}
		
	}
}
</style>
